package yxy.cherry.battle.module.affix.skill;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixFactory.SkillTypeEnum;
import yxy.cherry.battle.module.affix.Skill;
import yxy.cherry.battle.module.affix.SkillType;
import yxy.cherry.battle.module.record.stream.RecordStreamGroup;
import yxy.cherry.battle.module.record.stream.RecordStream_15_伤害吸血;
import yxy.cherry.battle.module.record.stream.RecordStream_SKL;
import yxy.cherry.data.bean.skill;

/**
 * 伤害治疗（回血只计算一次）
 * @author James
 * @Date 2022.3.7 10：32
 *  */

@SkillType(Type = SkillTypeEnum.伤害治疗)
public class Affix_12_伤害治疗 extends Skill {

	private int get治疗比例() {
		return getParam(0);
	}

	public Affix_12_伤害治疗(Fighter actor, skill skilldata, int probability, int[] params) {
		super(actor, skilldata, probability, params);
	}

	private RecordStreamGroup steamGroup;

	@Override
	public RecordStreamGroup record() {
		steamGroup = getRecord().stream(new RecordStreamGroup());
		steamGroup.add(new RecordStream_SKL(getActor(), getSkillId()));
		return steamGroup;
	}

	//2022.5.26 James 被群攻武将攻击时，需要按照平均伤害进行计算
	@Override
	public boolean exec(Fighter actor, Fighter target) {
		long 总伤害 = getAffixAction().总伤害();

		int targetNumber = getAffixAction().get目标们Fighter().size();
		long 治疗量 = 0;
		if(targetNumber > 0) {
			治疗量 = (总伤害 / targetNumber) * get治疗比例() / VALUE_比率分母;
		}

		actor.set治疗(治疗量);

		// 流脚本
		steamGroup.add(new RecordStream_15_伤害吸血(actor, 治疗量)).record();

		// 统计
		getRecord().get统计().getFighter(actor.getFighterPosition()).addCUR(治疗量);
		Battle.battleLogger(6,"伤害治疗："+actor.getName()+"目标数量："+targetNumber+"总伤害："+总伤害+"吸血比例："+get治疗比例()+"治疗量："+治疗量);
		return true;
	}
}